package com.manli.api.controller;

import com.manli.api.base.annotation.Permissions;
import com.manli.api.pojo.CouponGrant;
import com.manli.api.pojo.CouponGrantStop;
import com.manli.api.pojo.QueryParamsCouponBatch;
import com.manli.api.pojo.Result;
import com.manli.api.service.wechat.WechatPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "优惠券接口")
public class WeChatCouponController {
    @Autowired
    private WechatPayService wechatPayService;

//    @ApiOperation(value="微信优惠券logo上传", notes="微信优惠券logo上传")
//    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
//    @RequestMapping(value="/coupon/uploadLogoImg")
//    public Result uploadLogoImg(@RequestParam("file") MultipartFile file,@RequestBody  HttpServletRequest request) throws Exception {
//        return wechatPayService.uploadLogoImg(file,request);
//    }

    @ApiOperation(value="商户生成微信代金券", notes="商户生成微信代金券")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    @RequestMapping(value="/coupon/branchCreateCoupons")
    public Result branchCreateCoupons(@RequestBody CouponGrant couponGrant, HttpServletRequest request) throws Exception {
        return wechatPayService.branchCreateCoupons(couponGrant,request);
    }

    @ApiOperation(value="商户查询已经生成的微信代金券", notes="商户查询已经生成的微信代金券")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    @RequestMapping(value="/coupon/branchQueryCoupons")
    public Result branchQueryCoupons(@RequestBody QueryParamsCouponBatch queryParamsCouponBatch, HttpServletRequest request) throws Exception {
        return wechatPayService.branchQueryCoupons1(queryParamsCouponBatch,request);
    }

    @ApiOperation(value="商户重启或暂停生成的微信代金券", notes="商户重启或暂停生成的微信代金券")
    @Permissions(module = "", privilege = "", typeOfAccess = Permissions.METHOD_LOGIN)
    @RequestMapping(value="/coupon/branchStopCoupons")
    public Result branchStopCoupons(@RequestBody CouponGrantStop couponGrantStop, HttpServletRequest request) throws Exception {
        return wechatPayService.branchStopCoupons(couponGrantStop,request);
    }



}
